package org.springframework.extcache;

import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.extcache.AbstractConfiggurableCache.KeyValueParser;

/**
 * 可以配置的缓存
 * 
 * @version 1.0.0
 * @author zhangz8@yeah.net
 * @date 2019年12月19日上午07:22:36
 */
public interface ConfigurableCache extends Cache {

  String REPLACE_HEAD_REG  = "^(\\s*,\\s*)";
  String REPLACE_TAIL_REG  = "(\\s*,\\s*)$";
  String METHOD_PARAMS_KEY = "params";
  String EXPIRETIME_KEY    = "expireTime";
  String VERSION_KEY       = "version";

  /**
   * 获取缓存失效时间
   * 
   * @return
   */
  int getExpireTime();

  /**
   * 获取方法参数
   * 
   * @return
   */
  String getParams();

  /**
   * 获取缓存key
   * 
   * @return
   */
  String getActualKey();

  /**
   * 设置缓存key
   * 
   * @param actualKey
   */
  void setActualKey(String actualKey);
  
  String getOriginalKey();
  
  void setOriginalKey(String originalKey);

  /**
   * 是否已从远程容器装载
   * 
   * @return
   */
  boolean isLoaded();

  /**
   * 是否初始化完成，标志着actualKey有值，否则为null
   * 
   * @return
   */
  boolean isInitialized();

  void setIsInitialized(boolean isInitialized);

  /**
   * 获取缓存的值
   * 
   * @return
   */
  Object getValue();

  String getVersion();

  void setVersion(String version);

  CacheManager getCacheManager();

  void setCacheManager(CacheManager cacheManager);
  
  void setKeyValueParser(KeyValueParser keyValueParser);
}
